#ifndef DATA_MANAGER_HPP
#define DATA_MANAGER_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <map>
#include <string>

#include <SmegTools/Config.h>
#include <SmegTools/Pattern/Singleton.hpp>

#include <SmegTools/Debug/DebugNew.hpp>

namespace sf {
    class Texture;
}

namespace smeg {
    namespace core {
        
////////////////////////////////////////////////////////////
/// Keep track of loaded data to avoid loading the same thing multiple time
/// (eg. Image, Sound, etc...)
////////////////////////////////////////////////////////////
class DataManager : public tools::Singleton<DataManager>
{
    DECLARE_SINGLETON( DataManager )

public:
    ////////////////////////////////////////////////////////////
    /// DeInit the manager
    ///
    ////////////////////////////////////////////////////////////
    void                DeInit();

    ////////////////////////////////////////////////////////////
    /// Load a texture
    ///
    /// \param _TextureName :   Name to give to the texture
    /// \param _Filename :      Filename to load the texture
    /// \param _bIsRepeated :   Is the texture repeated ?
    /// \param _bIsSmooth :     Is the texture smooth ?
    /// \param _bForce :        Force the add if another texture exist with the given _TextureName
    ///
    /// \return The texture if it was properly loaded, otherwise NULL
    ///
    ////////////////////////////////////////////////////////////
    const sf::Texture*  AddTexture( const std::string& _TextureName, const std::string& _Filename, 
                                    bool _bIsRepeated = false, bool _bIsSmooth = false, bool _bForce = false );
    ////////////////////////////////////////////////////////////
    /// Remove a texture
    ///
    /// \param _TextureName : Name ot the texture to remove
    ///
    ////////////////////////////////////////////////////////////
    void                RemoveTexture( const std::string& _TextureName );
    ////////////////////////////////////////////////////////////
    /// Retrieve a loaded texture
    ///
    /// \param _TextureName : Name ot the texture to get
    ///
    /// \return The texture or NULL if no texture with _TextureName exist
    ///
    ////////////////////////////////////////////////////////////
    const sf::Texture*  GetTexture( const std::string& _TextureName ) const;

    ////////////////////////////////////////////////////////////
    /// Clear the loaded data
    ///
    ////////////////////////////////////////////////////////////
    void                ClearData();
    
private:
    typedef std::map< std::string, sf::Texture* >   td_MapTexture;

    /******************** Private members *********************/
    td_MapTexture       m_Textures;
};

    } // namespace core
} // namespace smeg

#include <SmegTools/Debug/DebugNewOff.hpp>

#endif // DATA_MANAGER_HPP
